<layout name="page"/>
<block name="content">
	{:widget('page_header/simple',array('name'=>'项目详情(完成'.$vo['finish_rate'].'%)'))}
	<div class="operate-panel">
		<a class="btn btn-return" onclick="go_return_url()">返回</a>
		<i class="mid"></i>
		<a class="btn btn-normal" onclick="add_task({$vo.id})">新建任务</a>
	</div>
	<div class="frame">
		<form enctype="multipart/form-data" id="form_data" method="post" name="form_data">
			<div class="box col-12">
				<label class="input-label" for="name"> 标题*： </label>
				<div class="input-box">
					{$vo.name}
				</div>
			</div>
			<div class="box col-12">
				<label class="input-label" for="name"> 日期*： </label>
				<div class="input-box">
					{$vo.start_date} ~ {$vo.end_date}
				</div>
			</div>
			<div class="box col-12">
				<label class="input-label" for="name"> 项目成员： </label>
				<div class="input-box">
					{:show_contact($vo['member'])}
				</div>
			</div>
			<foreach name="field_list" val="field_vo">
				{:widget('user_define_field/view',array($field_vo))}
			</foreach>
			<div class="box col-12">
				<label class="input-label"> 项目描述： </label>
				<div class="content-wrap">
					{$vo.content}
				</div>
			</div>
			<div class="box col-12">
				<label class="input-label"> 附件： </label>
				{:widget('file_upload/view',array('add_file'=>$vo['add_file']))}
			</div>
		</form>
	</div>
	{:widget('page_header/sub',array('name'=>'任务列表'))}
	<div class="tab-box">
		<div class="tab-header">
			<a class="active">全部</a>
			<a>待办中</a>
			<a>进行中</a>
			<a>延迟</a>
			<a>已完成</a>
			<a>已关闭</a>
		</div>
		<div class="tab-content x1">
			<!--全部-->
			<div class="table active">
				<ul>
					<li class="thead">
						<span class="w10 x1">任务名称</span>
						<span class="w6">工作量</span>
						<span class="w10">截至日期</span>
						<span class="w10">完成日期</span>
						<span class="w6">状态</span>
						<span class="w7">发起人</span>
						<span class="w7">执行人</span>
						<span class="w6">附件</span>
						<span class="w12">操作</span>
					</li>
					<foreach name="task_list_all" val="task" >
						<li class="tbody">
							<span class="w10 x1"> <a href="{:url('read_task',array('id'=>$task['id']))}"> {$task.name} </a> </span>
							<span class="w6"> {$task.workload} </span>
							<span class="w10"> {$task.end_date} </span>
							<span class="w10"> {$task.finish_date} </span>
							<span class="w6"> {$task['is_finish']} </span>
							<span class="w7"> {$task.user_name} </span>
							<span class="w7"> {$task.executor_name} </span>

							<if condition="empty($task['task_file'])">
								<span class="w6"></span>
								<else/>
								<span class="w6"> <a> <b onclick="download('{$task['task_file']}')"> 下载 </b> </a> </span>
							</if>

							<span class="w12">
								<if condition="$task['is_finish']<4 and $task['user_id'] == get_user_id()">
									<a href="{:url('Project/edit_task')}&id={$task.id}"> 修改 </a>
									<a onclick="del_task({$task.id})"> 删除 </a>
									<if condition="$task['is_finish'] == 3">
										<a onclick="close_task({$task.id})"> 关闭 </a>
									</if>
								</if></span>
						</li>
					</foreach>
				</ul>
			</div>
			<!--待办中-->
			<div class="table">
				<ul>
					<li class="thead">
						<span class="w10 x1">任务名称</span>
						<span class="w6">工作量</span>
						<span class="w10">截至日期</span>
						<span class="w10">完成日期</span>
						<span class="w6">状态</span>
						<span class="w7">发起人</span>
						<span class="w7">执行人</span>
						<span class="w6">附件</span>
						<span class="w12">操作</span>
					</li>
					<foreach name="task_list_todo" val="task" >
						<li class="tbody">
							<span class="w10 x1"> <a href="{:url('read_task',array('id'=>$task['id']))}"> {$task.name} </a> </span>
							<span class="w6">{$task.workload}</span>
							<span class="w10">{$task.end_date}</span>
							<span class="w10">{$task.finish_date}</span>
							<span class="w6">{$task['is_finish']}</span>
							<span class="w7">{$task.user_name}</span>
							<span class="w7">{$task.executor_name}</span>
							<if condition="empty($task['task_file'])">
								<span class="w6"></span>
								<else/>
								<span class="w6"> <a> <b onclick="download('{$task['task_file']}')"> 下载 </b> </a> </span>
							</if>

							<span class="w12">
								<if condition="$task['is_finish']<4 and $task['user_id'] == get_user_id()">
									<a href="{:url('Project/edit_task')}&id={$task.id}"> 修改 </a>
									<a onclick="del_task({$task.id})"> 删除 </a>
									<if condition="$task['is_finish'] == 3">
										<a onclick="close_task({$task.id})"> 关闭 </a>
									</if>
								</if></span>
						</li>
					</foreach>
				</ul>
			</div>
			<!--进行中-->
			<div class="table">
				<ul>
					<li class="thead">
						<span class="w10 x1">任务名称</span>
						<span class="w6">工作量</span>
						<span class="w10">截至日期</span>
						<span class="w10">完成日期</span>
						<span class="w6">状态</span>
						<span class="w7">发起人</span>
						<span class="w7">执行人</span>
						<span class="w6">附件</span>
						<span class="w12">操作</span>
					</li>
					<foreach name="task_list_working" val="task" >
						<li class="tbody">
							<span class="w10 x1"> <a href="{:url('read_task',array('id'=>$task['id']))}"> {$task.name} </a> </span>
							<span class="w6"> {$task.workload} </span>
							<span class="w10"> {$task.end_date} </span>
							<span class="w10"> {$task.finish_date} </span>
							<span class="w6"> {$task['is_finish']} </span>
							<span class="w7"> {$task.user_name} </span>
							<span class="w7"> {$task.executor_name} </span>
							<if condition="empty($task['task_file'])">
								<span class="w6"></span>
								<else/>
								<span class="w6"> <a> <b onclick="download('{$task['task_file']}')"> 下载 </b> </a> </span>
							</if>

							<span class="w12">
								<if condition="$task['is_finish']<4 and $task['user_id'] == get_user_id()">
									<a href="{:url('Project/edit_task')}&id={$task.id}"> 修改 </a>
									<a onclick="del_task({$task.id})"> 删除 </a>
									<if condition="$task['is_finish'] == 3">
										<a onclick="close_task({$task.id})"> 关闭 </a>
									</if>
								</if></span>
						</li>
					</foreach>
				</ul>
			</div>
			<!-- 延迟-->
			<div class="table">
				<ul>
					<li class="thead">
						<span class="w10 x1">任务名称</span>
						<span class="w6">工作量</span>
						<span class="w10">截至日期</span>
						<span class="w10">完成日期</span>
						<span class="w6">状态</span>
						<span class="w7">发起人</span>
						<span class="w7">执行人</span>
						<span class="w6">附件</span>
						<span class="w12">操作</span>
					</li>
					<foreach name="task_list_delay" val="task" >
						<li class="tbody">
							<span class="w10 x1"> <a href="{:url('read_task',array('id'=>$task['id']))}"> {$task.name} </a> </span>
							<span class="w6"> {$task.workload} </span>
							<span class="w10"> {$task.end_date} </span>
							<span class="w10"> {$task.finish_date} </span>
							<span class="w6"> {$task['is_finish']} </span>
							<span class="w7"> {$task.user_name} </span>
							<span class="w7"> {$task.executor_name} </span>
							<if condition="empty($task['task_file'])">
								<span class="w6"></span>
								<else/>
								<span class="w6"> <a> <b onclick="download('{$task['task_file']}')"> 下载 </b> </a> </span>
							</if>

							<span class="w12">
								<if condition="$task['is_finish']<4 and $task['user_id'] == get_user_id()">
									<a href="{:url('Project/edit_task')}&id={$task.id}"> 修改 </a>
									<a onclick="del_task({$task.id})"> 删除 </a>
									<if condition="$task['is_finish'] == 3">
										<a onclick="close_task({$task.id})"> 关闭 </a>
									</if>
								</if></span>
						</li>
					</foreach>
				</ul>
			</div>
			<!-- 已完成 -->
			<div class="table">
				<ul>
					<li class="thead">
						<span class="w10 x1">任务名称</span>
						<span class="w6">工作量</span>
						<span class="w10">截至日期</span>
						<span class="w10">完成日期</span>
						<span class="w6">状态</span>
						<span class="w7">发起人</span>
						<span class="w7">执行人</span>
						<span class="w6">附件</span>
						<span class="w12">操作</span>
					</li>
					<foreach name="task_list_finish" val="task" >
						<li class="tbody">
							<span class="w10 x1"> <a href="{:url('read_task',array('id'=>$task['id']))}"> {$task.name} </a> </span>
							<span class="w6"> {$task.workload} </span>
							<span class="w10"> {$task.end_date} </span>
							<span class="w10"> {$task.finish_date} </span>
							<span class="w6"> {$task['is_finish']} </span>
							<span class="w7"> {$task.user_name} </span>
							<span class="w7"> {$task.executor_name} </span>
							<if condition="empty($task['task_file'])">
								<span class="w6"></span>
								<else/>
								<span class="w6"> <a> <b onclick="download('{$task['task_file']}')"> 下载 </b> </a> </span>
							</if>

							<span class="w12">
								<if condition="$task['is_finish']<4 and $task['user_id'] == get_user_id()">
									<a href="{:url('Project/edit_task')}&id={$task.id}"> 修改 </a>
									<a onclick="del_task({$task.id})"> 删除 </a>
									<if condition="$task['is_finish'] == 3">
										<a onclick="close_task({$task.id})"> 关闭 </a>
									</if>
								</if></span>
						</li>
					</foreach>
				</ul>
			</div>
			<!-- 已关闭 -->
			<div class="table">
				<ul>
					<li class="thead">
						<span class="w10 x1">任务名称</span>
						<span class="w6">工作量</span>
						<span class="w10">截至日期</span>
						<span class="w10">完成日期</span>
						<span class="w6">状态</span>
						<span class="w7">发起人</span>
						<span class="w7">执行人</span>
						<span class="w6">附件</span>
						<span class="w12">操作</span>
					</li>
					<foreach name="task_list_close" val="task">
						<li class="tbody">
							<span class="w10 x1"> <a href="{:url('read_task',array('id'=>$task['id']))}"> {$task.name} </a> </span>
							<span class="w6"> {$task.workload} </span>
							<span class="w10"> {$task.end_date} </span>
							<span class="w10"> {$task.finish_date} </span>
							<span class="w6"> {$task['is_finish']} </span>
							<span class="w7"> {$task.user_name} </span>
							<span class="w7"> {$task.executor_name} </span>
							<if condition="empty($task['task_file'])">
								<span class="w6"></span>
								<else/>
								<span class="w6"> <a> <b onclick="download('{$task['task_file']}')"> 下载 </b> </a> </span>
							</if>

							<span class="w12">
								<if condition="$task['is_finish']<4 and $task['user_id'] == get_user_id()">
									<a href="{:url('Project/edit_task')}&id={$task.id}"> 修改 </a>
									<a onclick="del_task({$task.id})"> 删除 </a>
									<if condition="$task['is_finish'] == 3">
										<a onclick="close_task({$task.id})"> 关闭 </a>
									</if>
								</if></span>
						</li>
					</foreach>
				</ul>
			</div>
		</div>
	</div>
</block>
<block name="js">
	<script type="text/javascript">
		layui.use(['global'], function() {
			var $ = layui.jquery;
			var fn = {
				add_task : function(id) {
					window.open("{:url('add_task')}&project_id=" + id, "_self");
				},
				read_task : function(id) {
					window.open("{:url('read_task')}&id=" + id, "_self");
				},
				del_task : function(id) {
					layer.msg('确定要删除吗?', {
						time : 0,
						btn : ['确定', '取消'],
						yes : function(index) {
							var vars = "id=" + id;
							send_ajax("{:url('del_task')}", vars, function(ret) {
								if (ret.status) {
									layer.msg(ret.info, {
										time : 1500
									}, function() {
										location.reload(true);
									});
								} else {
									layer.msg(ret.info);
									return false;
								}
							});
						},
						no : function(index) {
							return false;
						}
					});
				},
				close_task : function(id) {
					layer.msg('确定要关闭任务吗?', {
						time : 0,
						btn : ['确定', '取消'],
						yes : function(index) {
							var vars = "id=" + id;
							send_ajax("{:url('close_task')}", vars, function(ret) {
								if (ret.status) {
									layer.msg(ret.info, {
										time : 1200
									}, function() {
										location.reload(true);
									});
								} else {
									layer.msg(ret.info);
									return false;
								}
							});
						},
						no : function(index) {
							return false;
						}
					});
				},
				download : function(file) {
					winopen("{:url('download')}?file=" + file, 560, 470);
				}
			};
			win_exp(fn);
			set_return_url();
		});

	</script>
</block>